"""
 猴子补丁：不改变类的实现  随着程序的运行 向类内添加新内容
"""

class Person:
    pass

p = Person()
p2 = Person()

# 1. 动态的添加实例属性
p.name = "qiku"
print(p.name)


def say_hello(self):
    print("hello")

import types
# 动态添加实例方法
p.say_hi = types.MethodType(say_hello, p)

p.say_hi()



# 动态添加类属性
Person.MAX_AGE = 250
print(Person.MAX_AGE, p.MAX_AGE, p2.MAX_AGE)


@classmethod
def class_info(cls):
    print(cls.__base__)


Person.class_info = class_info

Person.class_info()



@staticmethod
def sleep():
    print(f"好好学习，天天睡觉")

Person.sleep = sleep

Person.sleep()



property()